{include file="public/layout" /}
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;min-width:auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="order/left" /}
<div class="page min-hg-c-10" style="min-width:auto;margin-left:100px;">
    <div class="flexigrid flexigrid-xin">
        <div class="header-bar">
            <div class="more">
                <div class="search">
                    <div class="content">
                        <form id="postForm" action="{:url('Shop/index')}" method="get" onsubmit="layer_loading('正在处理');" style="display: unset;">
                            {$searchform.hidden|default=''}
                            <input type="hidden" name="order_status" value="{$Request.param.order_status}">
                            <div class="ey-form-item"><label class="users-form-item-label">关键词：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <!-- 订单号查询 -->
                                            <div class="sDiv2">
                                                <input type="text" size="50" name="order_code" id="order_code" value="{$Request.param.order_code}" class="qsbox" style="width: 170px;" placeholder="订单号或商品名称...">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="ey-form-item"><label class="users-form-item-label">支付方式：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="pay_name" id="pay_name">
                                                    <option value="" {empty name="$pay_name"}selected{/empty}>全部</option>
                                                    <option value="admin_pay" {eq name="$pay_name" value="admin_pay"}selected{/eq}>后台支付</option>
                                                    <option value="balance" {eq name="$pay_name" value="balance"}selected{/eq}>余额支付</option>
                                                    <option value="wechat" {eq name="$pay_name" value="wechat"}selected{/eq}>微信支付</option>
                                                    <option value="tikTokPay" {eq name="$pay_name" value="tikTokPay"}selected{/eq}>抖音支付</option>
                                                    <!-- <option value="baiduPay" {eq name="$pay_name" value="baiduPay"}selected{/eq}>百度支付</option> -->
                                                    <!-- {eq name="$openAliPay" value="0"}
                                                    <option value="alipay" {eq name="$pay_name" value="alipay"}selected{/eq}>支付宝支付</option>
                                                    {/eq} -->
                                                    <!-- {eq name="$shopOpenOffline" value="0"}
                                                    <option value="delivery_pay" {eq name="$pay_name" value="delivery_pay"}selected{/eq}>货到付款</option>
                                                    {/eq} -->
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="ey-form-item"><label class="users-form-item-label">订单来源：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="order_terminal" id="order_terminal">
                                                    <option value="0" {empty name="$order_terminal"}selected{/empty}>全部</option>
                                                    <option value="2" {eq name="$order_terminal" value="2"}selected{/eq}>H5</option>
                                                    <option value="3" {eq name="$order_terminal" value="3"}selected{/eq}>微信小程序</option>
                                                    <option value="9" {eq name="$order_terminal" value="9"}selected{/eq}>抖音小程序</option>
                                                    <option value="1" {eq name="$order_terminal" value="1"}selected{/eq}>PC</option>
                                                    <!-- <option value="10" {eq name="$order_terminal" value="10"}selected{/eq}>百度小程序</option> -->
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="ey-form-item"><label class="users-form-item-label">下单时间：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" name="add_time" id="eYLaydateTimeLinkage" data-max_date="{php}echo date('Y-m-d');{/php}" autocomplete="off"  class="qsbox" placeholder="下单时间" lay-key="1" style="width: 220px;" value="{$Request.param.add_time}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="ey-form-item"><label class="users-form-item-label">活动订单：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="act_type">
                                                    <option value="0" {if condition="!$Request.param.act_type"}selected{/if}>全部</option>
                                                    <option value="1" {eq name="$Request.param.act_type" value="1"} selected {/eq}>普通订单</option>
                                                    {notempty name="$seckill"}
                                                    <option value="2" {eq name="$Request.param.act_type" value="2"} selected {/eq}>秒杀订单</option>
                                                    {/notempty}
                                                    {notempty name="$pointsShop"}
                                                    <option value="3" {eq name="$Request.param.act_type" value="3"} selected {/eq}>积分订单</option>
                                                    {/notempty}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">配送方式：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="logistics_type">
                                                    <option value="0" {if condition="!$Request.param.logistics_type"}selected{/if}>全部</option>
                                                    <option value="1" {eq name="$Request.param.logistics_type" value="1"} selected {/eq}>快递发货</option>
                                                    <option value="2" {eq name="$Request.param.logistics_type" value="2"} selected {/eq}>到店核销</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <div class="ey-form-item ml20">
                            <div class="users-form-item-content">
                                <span class="bt-xin" onclick="OrderQuery();">查询</span>
                                <span class="bt-xin-no" onclick="OrderQuery('reset');">重置</span>
                                <!-- <div class="fbutton">
                                    <a href="javascript:void(0);" onclick="OrderExcelExport(this);" data-url="{:url('Order/ajax_order_excel_export')}" class="bt-xin-xia"><i class="iconfont e-xiazai"></i>导出</a>
                                </div> -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="flexigrid flexigrid-xin mt10">
        <div class="tableDiv bubbleInfo">
            <table cellspacing="0" cellpadding="0" style="width: 100%;">
                <thead>
                    <tr>
                        <th> <div class="">商品信息</div> </th>
                        <th class="w240"> <div class="">单价/数量</div> </th>
                        <th class="w240"> <div class="">实付款</div> </th>
                        <th class="w240"> <div class="">收货人</div> </th>
                        <th class="w160"> <div class="">配送</div> </th>
                        <th class="w160"> <div class="">状态</div> </th>
                        <th class="w180"> <div class="">操作</div> </th>
                    </tr>
                </thead>
                <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                        {volist name="list" id="vo"}
                            <tr class="order-empty"><td colspan="8"></td></tr>
                            <tr>
                                <td class="biaotou" colspan="8">
                                    <span class="mr15" style=" display: flex; flex-direction: row; align-items: center;">
                                        <!-- <i class="iconfont e-pintuan1 f-18 orange mr5"></i> -->
                                        {notempty name="$seckill"}
                                            {notempty name="$vo.is_seckill_order" value="0"}
                                            <i class="iconfont e-miaoshashangpin f-18 orange mr5"></i>
                                            {/notempty}
                                        {/notempty}
                                        {notempty name="$vo.points_shop_order"}<i class="iconfont e-wodejifen f-18 orange mr5"></i>{/notempty}
                                        <i class="iconfont e-shijian"></i>
                                        <span class="mr15">{$vo.add_time}</span>
                                        <span class="mr15">
                                            订单号：{$vo.order_code} <a class="copy order_code" onclick="OrderCopy();" data-clipboard-text="{$vo.order_code}"><i class="iconfont e-fuzhi f-16"></i></a>
                                        </span>
                                        <span class="mr15">支付方式：{$pay_method_arr[$vo.pay_name]|default='未付款'}
                                        </span>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                {volist name="$vo.Details" id="do"}
                                    {eq name="$i" value="1"}
                                    <td>
                                        <div class="goods-detail pl3">
                                            <div class="goods-image pl0">
                                                <a href="{$do.arcurl}" target="_blank"><img src="{$do.litpic}"></a>
                                            </div>
                                            <div class="goods-info">
                                                <p class="goods-title">{$do.product_name}</p>
                                                {notempty name="$do.spec_value_list"}
                                                <p class="goods-spec">{volist name="$do.spec_value_list" id="sp"}<span>{$sp.value}</span>{/volist}</p>
                                                {/notempty}
                                                {if condition="!empty($do.apply_service) && !empty($do.service_id)"}
                                                <p class="after-sale"><span>售后-{$do.status_name}</span><a data-href="{:url('ShopService/after_service_details', array('service_id' => $do['service_id'], 'iframe' => 1))}" onclick="openFullframe(this, '售后详情', '99%', '99%');">售后详情</a></p>
                                                {/if}
                                            </div>
                                        </div>
                                    </td>
                                    <td class=""><p>{empty name="$vo.points_shop_order"}￥{/empty}{$do.product_price} x {$do.num}</p>{if condition="!empty($do.actualPayPrice)"}<p class="dispatch">实付款￥{$do.actualPayPrice}</p>{/if}</td>
                                    {/eq}
                                {/volist}

                                <td class="" rowspan="{$vo.rowspan}">
                                    <p style="color: #636669; font-weight: 600;">{empty name="$vo.points_shop_order"}￥{/empty}{$vo.order_amount} <span style="font-weight: 400;">(含运费：￥{$vo.shipping_fee})</span></p>
                                </td>
                            
                                <td class="" rowspan="{$vo.rowspan}">
                                    {eq name="$vo.prom_type" value="0"}
                                    <p style="line-height: 1.5;"><a class="basics-color" href="javascript:void(0);" data-href="{:url('Member/users_edit', ['id'=>$vo.users_id,'from'=>'money_index','iframe'=>1])}" {empty name='$iframe'} onclick="openFullframe(this, '会员资料','100%','100%');" {else /} onclick="parent_openFullframe(this, '会员资料','100%','100%');" {/empty}>{$vo.u_nickname}</a></p>
                                    <p style="line-height: 1.5;">{$vo.consignee}&nbsp;&nbsp;{$vo.mobile}</p>
                                    <span class="address_box">{$vo.province_text}-{$vo.city_text}-{$vo.district_text}-{$vo.address}</span>
                                    <a class="copy address_code" onclick="AddressCopy();" data-clipboard-text="{$vo.province_text}-{$vo.city_text}-{$vo.district_text}-{$vo.address},收货人：{$vo.consignee},手机号：{$vo.mobile}"><i class="iconfont e-fuzhi f-16"></i></a>
                                    {else/}
                                    <p><a href="javascript:void(0);" data-href="{:url('Member/users_edit', ['id'=>$vo.users_id,'from'=>'money_index','iframe'=>1])}" {empty name='$iframe'} onclick="openFullframe(this, '会员资料','100%','100%');" {else /} onclick="parent_openFullframe(this, '会员资料','100%','100%');" {/empty}>{$vo.u_nickname}</a></p>
                                    <p>{$vo.u_mobile}</p>
                                    {/eq}
                                </td>
                                <td class="" rowspan="{$vo.rowspan}">
                                    <span class="am-badge am-badge-secondary">{if condition="$vo.prom_type == 0"}{eq name="$vo.logistics_type" value="1"}快递{else/}到店自提{/eq}{elseif condition="$vo.prom_type == 1"}无需物流{/if}</span>
                                </td>

                                <td class="" rowspan="{$vo.rowspan}">
                                    <p>
                                        <span class="zt {eq name='$vo.order_status' value='0'}show{else/}none{/eq}" style="color: #ff1f2c">待付款</span>
                                        {eq name="$vo.logistics_type" value="2"}
                                        <span class="zt {eq name='$vo.order_status' value='1'}show{else/}none{/eq}" style="color: #2d8cf0;">待核销</span>
                                        {else /}
                                        <span class="zt {eq name='$vo.order_status' value='1'}show{else/}none{/eq}" style="color: #ff9900">待发货</span>
                                        {/eq}
                                        <span class="zt {eq name='$vo.order_status' value='2'}show{else/}none{/eq}" style="color: #2d8cf0;">已发货</span>
                                        <span class="zt {eq name='$vo.order_status' value='3'}show{else/}none{/eq}" style="color: #19be6b;">已完成</span>
                                        <span class="zt {eq name='$vo.order_status' value='-1'}show{else/}none{/eq}" style="color: #939799;">已关闭</span>
                                    </p>
                                    
                                </td>
                                <td rowspan="{$vo.rowspan}">
                                    <div class="operation">
                                        
                                        {eq name="$vo.order_status" value='0'}
                                        <!-- 订单未付款时出现 -->
                                        <a href="JavaScript:void(0);" onclick="OrderMark('yfk', '{$vo.order_id}', '{$vo.users_id}');" class="bt">确认付款</a>
                                        <a href="JavaScript:void(0);" onclick="PromptChangePrice('{$vo.order_id}', '{$vo.order_amount}');" class="bt">订单改价</a>
                                        <script type="text/javascript">
                                            // 弹出改价输入框
                                            function PromptChangePrice(order_id, order_amount) {
                                                layer.prompt({
                                                    formType: 3,
                                                    shade: layer_shade,
                                                    move: false,
                                                    title: '提示',
                                                    id: 'BulkSetPrice',
                                                    btnAlign:'r',
                                                    closeBtn: 3,
                                                    btn: ['确定', '关闭'],
                                                    success: function(layero, index) {
                                                        $("#BulkSetPrice").find('input').attr('placeholder', '请输入应付金额');
                                                        $("#BulkSetPrice").find('input').attr('value', order_amount);
                                                        $("#BulkSetPrice").find('input').attr('onkeyup', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                                        $("#BulkSetPrice").find('input').attr('onpaste', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                                        var msg = '<span style="color: red;">改价后让用户重新进入订单列表点击支付</span>';
                                                        $("#BulkSetPrice").append(msg);
                                                        // 修改订单金额后为保证支付金额准确有效<br/>请让用户刷新订单列表页后重新点击支付
                                                    }
                                                }, function(price, index) {
                                                    if (0 < price) {
                                                        layer.close(index);
                                                        OrderChangePrice(order_id, order_amount, price);
                                                    } else {
                                                        layer.msg('应付金额不允许为0', {time: 1500});
                                                    }
                                                });
                                            }

                                            // 提交改价数据并追加一条订单操作记录
                                            function OrderChangePrice(OrderID, OrderAmount, Price) {
                                                if (0 >= Price) layer.msg('应付金额不允许为0', {time: 1500});
                                                layer_loading('正在处理');
                                                $.ajax({
                                                    type : 'post',
                                                    url  : "{:url('Shop/order_change_price')}",
                                                    data : {
                                                        order_id: OrderID,
                                                        order_amount_old: OrderAmount,
                                                        order_amount: Price,
                                                        _ajax: 1
                                                    },
                                                    dataType : 'json',
                                                    success : function(res) {
                                                        layer.closeAll();
                                                        if (1 == res.code) {
                                                            layer.msg(res.msg, {time: 1500}, function() {
                                                                window.location.reload();
                                                            });
                                                        } else {
                                                            layer.alert(res.msg, {title: false, closeBtn: 0}, function() {
                                                                window.location.reload();
                                                            });
                                                        }
                                                    }
                                                });
                                            }
                                        </script>
                                        <a href="JavaScript:void(0);" onclick="OrderMark('gbdd', '{$vo.order_id}', '{$vo.users_id}');" class="bt">关闭订单</a>
                                        <!-- END -->
                                        {/eq}
                                        
                                        {if condition="1 == $vo.order_status"}
                                        {eq name="$vo.logistics_type" value="2"}
                                        <a href="JavaScript:void(0);" onclick="OrderVerify('{$vo.order_id}','{$vo.users_id}');" class="bt">确认核销</a>
                                        {else /}
                                        <a href="JavaScript:void(0);" data-url="{:url('Shop/order_send', ['order_id'=>$vo.order_id])}" onclick="OrderSend(this);" class="bt">确认发货</a>
                                        {notempty name="$LogData[$vo.order_id]['action_count']"}
                                        <span class="bt">发货提醒<em class="num">{$LogData[$vo.order_id]['action_count']}</em></span>
                                        {/notempty}
                                        {/eq}
                                        <!-- 订单待发货时出现 -->
                                        <!-- <a class="bt" href="javascript:void(0);" onclick="OrderMark('sdtk', '{$vo.order_id}');">手动退款</a> -->
                                        {/if}

                                        {if condition="2 == $vo.order_status"}
                                        <!-- 订单已发货时出现 -->
                                        <!-- <a class="bt" href="javascript:void(0);" onclick="OrderMark('sdtk', '{$vo.order_id}');">手动退款</a> -->
                                        <a href="JavaScript:void(0);" onclick="OrderMark('ysh','{$vo.order_id}','{$vo.users_id}');" class="bt">确认收货</a>
                                        <input type="hidden" id="beizhu-url" value="{:url('Shop/update_note')}">
                                        <a class="bt" href="javascript:void(0);" data-href="{:url('shop/order_remarks', ['order_id'=>$vo.order_id])}" onclick="openFullframe(this, '商家备注', '600px', '55%');" title="订单备注">订单备注</a>
                                        {/if}

                                        {if condition="in_array($vo.order_status, [1, 2])"}
                                        <a class="bt" href="javascript:void(0);" data-href="{:url('shop/order_active_refund', ['order_id'=>$vo.order_id])}" onclick="openFullframe(this, '店铺主动退款', '674px', '70%');">主动退款</a>
                                        {/if}

                                        {if condition="-1 == $vo.order_status or 3 == $vo.order_status"}
                                        <a class="bt" href="javascript:void(0);" data-href="{:url('shop/order_remarks', ['order_id'=>$vo.order_id])}" onclick="openFullframe(this, '商家备注', '600px', '55%');" title="订单备注">订单备注</a>
                                        <input type="hidden" id="beizhu-url" value="{:url('Shop/update_note')}">
                                        <a class="bt" href="JavaScript:void(0);" onclick="OrderMark('ddsc','{$vo.order_id}','{$vo.users_id}');">订单删除</a>
                                        {/if}

                                        {if condition="-1 == $vo.order_status and 1 == $vo.manual_refund"}
                                        <!-- 订单已发货时出现 -->
                                        <a href="JavaScript:void(0);" onclick="BrowseRefundNote('{$vo.refund_note}');" class="bt">退款备注</a>
                                        {/if}
                                        <a class="bt" href="{:url('Shop/order_details',array('order_id'=>$vo['order_id']))}">订单详情</a>
                                    </div>
                                </td>
                            </tr>

                            {volist name="$vo.Details" id="do"}
                                {gt name="$i" value="1"}
                                <tr>
                                    <td>
                                        <div class="goods-detail pl3">
                                            <div class="goods-image pl0">
                                                <a href="{$do.arcurl}" target="_blank"><img src="{$do.litpic}"></a>
                                            </div>
                                            <div class="goods-info">
                                                <p class="goods-title">{$do.product_name}</p>
                                                {notempty name="$do.spec_value_list"}
                                                <p class="goods-spec">{volist name="$do.spec_value_list" id="sp"}<span>{$sp.value}</span>{/volist}</p>
                                                {/notempty}
                                                {if condition="!empty($do.apply_service) && !empty($do.service_id)"}
                                                <p class="after-sale"><span>售后-{$do.status_name}</span><a data-href="{:url('ShopService/after_service_details', array('service_id' => $do['service_id'], 'iframe' => 1))}" onclick="openFullframe(this, '售后详情', '99%', '99%');">售后详情</a></p>
                                                {/if}
                                            </div>
                                        </div>
                                    </td>
                                    <td class=""><p>{empty name="$vo.points_shop_order"}￥{/empty}{$do.product_price} X {$do.num}</p>{if condition="!empty($do.actualPayPrice)"}<p class="dispatch">实付款￥{$do.actualPayPrice}</p>{/if}</td>
                                </tr>
                                {/gt}
                            {/volist}
                        {/volist}
                    {/empty}
                </tbody>
            </table>
        </div>
        {notempty name="list"}
        <div class="tDiv">
            <div class="tDiv2">
                {include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
        {/notempty}
    </div>
</div>

<script type="text/javascript">
    $(function() {
        $('input[name*=ids]').click(function() {
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });

    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#add_time_begin' //指定元素
        });
        laydate.render({
            elem: '#add_time_end' //指定元素
        });
    });

    $(document).ready(function() {
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function() {
            $(this).toggleClass('trSelected');
        });
    });

    // AJAX调用下载
    function OrderExcelExport(obj) {
        layer_loading('订单导出中');
        $.ajax({
            type: 'post',
            url : $(obj).attr('data-url'),
            data: {
                _ajax: 1,
                // 导出类型，商城订单固定值1
                export_type: 1,
                // 搜索条件信息，可为空
                pay_name: "{$pay_name}",
                order_code: "{$Request.param.order_code}",
                end_time: "{$Request.param.add_time_end}",
                start_time: "{$Request.param.add_time_begin}",
                order_status: "{$Request.param.order_status}",
                order_terminal: "{$order_terminal}",
                contains_virtual: "{$contains_virtual}",
            },
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    window.location.href = res.url;
                } else {
                    showErrorAlert(res.msg);
                }
            },
            error: function(e) {
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    // 订单号复制
    function OrderCopy() {
        var clipboard1 = new Clipboard(".order_code");
        clipboard1.on("success", function(e) {
            layer.msg("复制成功");
        });
        clipboard1.on("error", function(e) {
            layer.msg("复制失败！请手动复制", {icon: 5});
        }); 
    }
    // 地址复制
    function AddressCopy() {
        var clipboard1 = new Clipboard(".address_code");
        clipboard1.on("success", function(e) {
            layer.msg("复制成功");
        });
        clipboard1.on("error", function(e) {
            layer.msg("复制失败！请手动复制", {icon: 5});
        }); 
    }

    // 订单查询
    function OrderQuery(isReset) {
        if (isReset && 'reset' == isReset) {
            window.location.href = "{:url('Shop/index', ['order_status'=>$Request.param.order_status])}";
        } else {
            $('#postForm').submit();
        }
    }

    // 订单发货
    function OrderSend(obj) {
        var url = $(obj).attr('data-url');

        // iframe窗
        var iframes = layer.open({
            type: 2,
            title: '订单发货详情',
            fixed: true, //不固定
            shadeClose: false,
            shade: layer_shade,
            area: ['694px', '600px'],
            content: url
        });
        // layer.full(iframes);
    }

    // 订单操作
    function OrderMark(status_name, order_id, users_id, admin_note, update_time) {
        if('yfk' == status_name) {
            var msg = '确认订单已付款？';
        } else if ('ysh' == status_name) {
            var msg = '确认订单已收货？';
        } else if ('gbdd' == status_name) {
            var msg = '确认关闭订单？';
        } else if ('ddbz' == status_name) {
            layer.prompt({
                formType: 2,
                shade: layer_shade,
                value: admin_note,
                title: '提示',
                closeBtn: 3,
                id: 'AdminNote',
                area: ['300px', '100px'],
                success: function(layero, index) {
                    if (admin_note) {
                        var msg = '<br/><span style="color: #999; font-size: 12px;">最后更新：'+update_time+'</span>';
                        $("#AdminNote").append(msg);
                        $(".layui-layer-content").css('text-align', 'left');
                    }
                }
            }, function(value, index, elem) {
                OrderNote(order_id,value);
                layer.close(index);
            });
            return false;
        } else if ('sdtk' == status_name) {
            layer.prompt({
                formType: 2,
                shade: layer_shade,
                value: '',
                title: '提示',
                closeBtn: 3,
                id: 'manualRefund',
                btnAlign:'r',
                btn: ['确定', '取消'],
                area: ['300px', '120px'],
                success: function(layero, index) {
                    $("#manualRefund").find('textarea').attr('placeholder', '请填写退款原因(非必填)');
                    var msg = '<span class="f-16 mb5" style="display: block;">是否关闭订单并自行手动退款</span><span class="red f-12">此操作系统不会自动退款，需手动线下退款</span><br/><br/>';
                    $("#manualRefund").prepend(msg);
                    $(".layui-layer-content").css('text-align', 'left');
                },
                yes: function(index, layero) {
                    // 手动关闭订单并退款
                    var value = $("#manualRefund").find("textarea").val();
                    ManualRefund(order_id, value);
                    layer.close(index);
                }
            });
            return false;
        } else if ('ddsc' == status_name) {
            var msg = '确认删除订单？';
        }

        layer.confirm(msg, {
            shade: layer_shade,
            title: '提示',
            closeBtn: 3,
            btnAlign:'r',
            btn: ['确定','取消'],
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function() {
            $.ajax({
                url: "{:url('Shop/order_mark_status')}",
                data: {order_id:order_id,status_name:status_name,users_id:users_id, _ajax:1},
                type:'post',
                dataType:'json',
                success:function(res) {
                    layer.closeAll();
                    if (1 == res.code) {
                        if (!res.data.email && !res.data.mobile && !res.data.weChat) {
                            showSuccessMsg(res.msg, 1500, function() {
                                window.location.reload();
                            });
                        } else {
                            if (res.data.email) unifySendEmail(res.data.email);
                            if (res.data.mobile) unifySendMobile(res.data.mobile);
                            if (res.data.weChat) unifySendWeChat(res.data.weChat);
                            showSuccessMsg('发货成功', 1500, function() {
                                window.location.reload();
                            });
                        }
                    } else {
                        layer.msg(res.msg, {time: 1500});
                    }
                }
            });
        },function(index) {
            layer.closeAll(index);
        });
    }

    // 订单备注
    function OrderNote(order_id, admin_note) {
        $.ajax({
            url: "{:url('Shop/update_note')}",
            data: {order_id:order_id,admin_note:admin_note, _ajax:1},
            type:'post',
            dataType:'json',
            success:function(res){
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {time: 1500},function(){
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {time: 1500});
                }
            }
        });
    }

    // 手动关闭订单并退款
    function ManualRefund(order_id, refund_note) {
        $.ajax({
            url: "{:url('Shop/order_manual_refund')}",
            data: {order_id: order_id, refund_note: refund_note, _ajax: 1},
            type:'post',
            dataType:'json',
            success:function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {time: 1500}, function() {
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {time: 1500});
                }
            }
        });
    }

    // 查看手动退款原因
    function BrowseRefundNote(layer_str) {
        if (!layer_str) layer_str = '未填写备注信息';
        layer.confirm(layer_str, {title: '提示', shade: layer_shade, closeBtn: 3, btn: ['关闭'], btnAlign:'r', area: ['25%', '25%'],
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }});
    }

    function OrderVerify(order_id, users_id) {
        // 是否开启核销功能
        var openVerify = "{$weappInfo['data']['openVerify']|default=0}";
        if (0 === parseInt(openVerify)) {
            layer.alert('已关闭核销功能，核销订单将无法操作', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            });
            return false;
        }

        // 是否开启后台二次核销
        var openSecondVerify = "{$weappInfo['data']['openSecondVerify']|default=0}";
        layer.confirm('核销后用户的核销凭证将失效，确认核销此单?', {
            shade: layer_shade,
            title: '提示',
            closeBtn: 3,
            btnAlign:'r',
            btn: ['确定','取消'],
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
                if (1 === parseInt(openSecondVerify)) {
                    var html = '<div style="padding: 0  0 10px 20px; color: red;">请输入核销码二次验证:</div><input type="text" id="verify_code" style="margin-left: 20px; margin-bottom: 5px;" placeholder="请输入订单核销码"/></div>';
                        $(".layui-layer-content").after(html);
                }
            }
        }, function() {
            var verify_code = 1 === parseInt(openSecondVerify) ? $("#verify_code").val() : '';
            if ('' == verify_code && 1 === parseInt(openSecondVerify)) {
                $('#verify_code').focus();
                return false;
            }
            layer_loading('正在处理');
            $.ajax({
                url: "{:url('Shop/verify')}",
                data: {order_id: order_id, verify_code: verify_code, users_id: users_id, _ajax: 1},
                type:'post',
                dataType:'json',
                success:function(res) {
                    layer.closeAll();
                    if (1 == res.code) {
                        layer.msg(res.msg, {time: 1500},function(){
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {time: 1500});
                    }
                }
            });
        },function(index) {
            layer.closeAll(index);
        });
    }
</script>
<!-- 日期联动选择js文件 start -->
<script type="text/javascript" src="__PUBLIC__/static/common/js/ey_laydate_time_linkage.js?v={$version}"></script>
<!-- 日期联动选择js文件 end -->
{include file="public/footer" /}